﻿using System.IO;
using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Zip;

public class ZIPExample
{
    private const string INPUT_FILE = "P1040363.jpg";
   
    public static void Main()
    {
        ZipOutputStream outputStream = new ZipOutputStream(File.Create("pesho.zip"));
        byte[] buffer = new byte[4096];
        using (outputStream)
        {
            outputStream.SetLevel(9);
            ZipEntry entry = new ZipEntry(INPUT_FILE);
            outputStream.PutNextEntry(entry);
            FileStream stream = new FileStream(INPUT_FILE, FileMode.Open);
            using (stream)
            {
                StreamUtils.Copy(stream, outputStream, buffer);
            }
        }
        ZipInputStream inputStream = new ZipInputStream(File.Open("pesho.zip", FileMode.Open));
        using (inputStream)
        {
            ZipEntry entry = inputStream.GetNextEntry();
            FileStream stream = new FileStream("new.png", FileMode.Create);
            using (stream)
            {
                StreamUtils.Copy(inputStream, stream, buffer);
            }
        }
    }    
}